package com.nginx.web.util;


import java.util.HashMap;
import java.util.Map;

public class DbUtil {


    public static String replace(String sqlTxt, HashMap<String,Object> hashMap) {
        String sql = sqlTxt;
        for(Map.Entry<String, Object> entry: hashMap.entrySet()){
            Object value = entry.getValue();
            if(value instanceof String){
                sql = sql.replaceAll("#\\{" + entry.getKey() + "\\}" , "'" + value + "'");
            }else{
                sql = sql.replaceAll( "#\\{" + entry.getKey() + "\\}", "" + value);
            }
        }
        return sql;
    }



}
